//
//  WYCRmtCell.m
//  初试
//
//  Created by 中企互联 on 2017/10/11.
//  Copyright © 2017年 李胜军. All rights reserved.
//

#import "WYCRmtCell.h"

@implementation WYCRmtCell

+ (instancetype)cellWithTableView:(UITableView *)tableView{
    WYCRmtCell * cell = [tableView dequeueReusableCellWithIdentifier:[WYCRmtCell ID]];
    cell = [[WYCRmtCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:[WYCRmtCell ID]];
    
    return cell;
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setMember];
        
    }
    return self;
}
//cell控件摆放
- (void)setMember{
    
    
    
    UIView  * bankImageView = [[UIView alloc] init];
    bankImageView.frame  = CGRectMake(20 * px, 20 * px, ScreenWidth - 20 * px * 2, 340 * px);
//    bankImageView.image = [UIImage imageNamed:@"back_red"];
//    bankImageView.backgroundColor = [UIColor redColor];
    bankImageView.layer.cornerRadius = 5;
    bankImageView.layer.masksToBounds = YES;
    [self.contentView addSubview:bankImageView];
    self.bankView = bankImageView;
    

    /** 银行图标*/
    CGFloat bankimageViewX = 40 * px;
    CGFloat bankimageViewW = 80 * px;

    UIImageView * bigbankImageView = [[UIImageView alloc] init];
    bigbankImageView.frame  = CGRectMake(bankimageViewX, bankimageViewX, bankimageViewW, bankimageViewW);
    
    [bankImageView addSubview:bigbankImageView];
    self.bigbankImageView = bigbankImageView;

    /** 银行名称*/
    self.banklabel = [[UILabel alloc] init];
    self.banklabel.frame = CGRectMake(CGRectGetMaxX(bigbankImageView.frame) + 40 * px, bigbankImageView.y, ScreenWidth / 2, 62 * px);
//    banklabel.text = @"招商银行";
    self.banklabel.textColor = [UIColor whiteColor];
    self.banklabel.font = [UIFont systemFontOfSize:MiddleFont];
    [bankImageView addSubview:self.banklabel];
//
//
    /** 姓名*/
    UILabel * typeBanklabel = [[UILabel alloc] init];
    typeBanklabel.frame = CGRectMake(bankImageView.width - 190 * px, _banklabel.y, 150 * px, 62 * px);
    typeBanklabel.text = @"信用卡";
    typeBanklabel.textColor = [UIColor whiteColor];
    typeBanklabel.font = [UIFont systemFontOfSize:SmallFont];
    [bankImageView addSubview:typeBanklabel];

    /** 卡号*/
    self.lastNumberLabel = [[UILabel alloc] init];
    self.lastNumberLabel.frame = CGRectMake(_banklabel.x, CGRectGetMaxY(_banklabel.frame) + 40 * px, bankImageView.width, 62 * px);
    self.lastNumberLabel.textColor = [UIColor whiteColor];
    self.lastNumberLabel.font = [UIFont systemFontOfSize:MiddleFont];
    [bankImageView addSubview:self.lastNumberLabel];

    
    /** 还款日*/
    self.staylabel = [[UILabel alloc] init];
    self.staylabel.frame = CGRectMake(_lastNumberLabel.x, CGRectGetMaxY(_lastNumberLabel.frame) + 40 * px, bankImageView.width, 62 * px);
    self.staylabel.textColor = [UIColor whiteColor];
    self.staylabel.font = [UIFont systemFontOfSize:MiddleFont];
    [bankImageView addSubview:self.staylabel];

}
- (void)setRmtModel:(WYCRmtModel *)RmtModel{
    _RmtModel = RmtModel;
    
    //招商银行
    if ([RmtModel.bankId isEqualToString:@"10000"]) {
      //招商银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_zs"];
        self.bankView.backgroundColor = [UIColor redColor];
        
    }else if ([RmtModel.bankId isEqualToString:@"10001"]) {
        //工商银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_gs"];
        self.bankView.backgroundColor = [UIColor redColor];
        
    }else if ([RmtModel.bankId isEqualToString:@"10002"]) {
        //农业银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_ny"];
        self.bankView.backgroundColor = [UIColor greenColor];
        
    }else if ([RmtModel.bankId isEqualToString:@"10003"]) {
        //建设银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_js"];
        self.bankView.backgroundColor = [UIColor blueColor];
        
    }else if ([RmtModel.bankId isEqualToString:@"10004"]) {
        //中国银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_zg"];
        self.bankView.backgroundColor = [UIColor redColor];
        
    }else if ([RmtModel.bankId isEqualToString:@"10005"]) {
        //浦发银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_pf"];
        self.bankView.backgroundColor = [UIColor blueColor];
        
    }else if ([RmtModel.bankId isEqualToString:@"10006"]) {
        //交通银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_jt"];
        self.bankView.backgroundColor = [UIColor blueColor];
        
    }else if ([RmtModel.bankId isEqualToString:@"10007"]) {
        //民生银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_ms"];
        self.bankView.backgroundColor = [UIColor greenColor];
        
    }else if ([RmtModel.bankId isEqualToString:@"10008"]) {
        //深圳发展银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_sf"];
        self.bankView.backgroundColor = [UIColor blueColor];
        
    }else if ([RmtModel.bankId isEqualToString:@"10009"]) {
        //广东发展银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_gf"];
        self.bankView.backgroundColor = [UIColor redColor];
        
    }else if ([RmtModel.bankId isEqualToString:@"10010"]) {
        //中信银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_zx"];
        self.bankView.backgroundColor = [UIColor redColor];
        
    }else if ([RmtModel.bankId isEqualToString:@"10011"]) {
        //华夏银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_hx"];
        self.bankView.backgroundColor = [UIColor redColor];
        
    }else if ([RmtModel.bankId isEqualToString:@"10012"]) {
        //兴业银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_xy"];
        self.bankView.backgroundColor = [UIColor blueColor];
        
    }else if ([RmtModel.bankId isEqualToString:@"10013"]) {
        
        //广州银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_gz"];
        self.bankView.backgroundColor = [UIColor redColor];
    }else if ([RmtModel.bankId isEqualToString:@"10014"]) {
        
        // 江苏银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_jiangsu"];
        self.bankView.backgroundColor = [UIColor blueColor];
    }else if ([RmtModel.bankId isEqualToString:@"10015"]) {
        
        //上海农村商业银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_shnos"];
        self.bankView.backgroundColor = [UIColor blueColor];
    }else if ([RmtModel.bankId isEqualToString:@"10016"]) {
        
        //北京银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_bj"];
        self.bankView.backgroundColor = [UIColor redColor];
    }else if ([RmtModel.bankId isEqualToString:@"10017"]) {
        
        //渤海银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_other"];
        self.bankView.backgroundColor = [UIColor blueColor];
    }else if ([RmtModel.bankId isEqualToString:@"10018"]) {
        
        //北京农商银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_bjns"];
        self.bankView.backgroundColor = [UIColor redColor];
    }else if ([RmtModel.bankId isEqualToString:@"10019"]) {
        
        //南京银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_njbank"];
        self.bankView.backgroundColor = [UIColor redColor];
    }else if ([RmtModel.bankId isEqualToString:@"10020"]) {
        
        //光大银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_gd"];
        self.bankView.backgroundColor = WYCRGBColor(160, 32, 240);
    }else if ([RmtModel.bankId isEqualToString:@"10021"]) {
        
        //东亚银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_dy"];
        self.bankView.backgroundColor = [UIColor redColor];
    }else if ([RmtModel.bankId isEqualToString:@"10022"]) {
        
        //宁波银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_nb"];
        self.bankView.backgroundColor = WYCRGBColor(160, 32, 240);
    }else if ([RmtModel.bankId isEqualToString:@"10023"]) {
        
        //杭州银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_hz"];
        self.bankView.backgroundColor = [UIColor blueColor];
    }else if ([RmtModel.bankId isEqualToString:@"10024"]) {
        
        //平安银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_pa"];
        self.bankView.backgroundColor = [UIColor redColor];
    }else if ([RmtModel.bankId isEqualToString:@"10025"]) {
        
        //徽商银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_other"];
        self.bankView.backgroundColor = [UIColor redColor];
    }else if ([RmtModel.bankId isEqualToString:@"10026"]) {
        
        // 浙商银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_other"];
        self.bankView.backgroundColor = WYCRGBColor(160, 32, 240);
    }else if ([RmtModel.bankId isEqualToString:@"10027"]) {
        
        //上海银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_other"];
        self.bankView.backgroundColor = WYCRGBColor(160, 32, 240);
    }else if ([RmtModel.bankId isEqualToString:@"10028"]) {
        
        // 中国邮政储蓄银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_hs"];
        self.bankView.backgroundColor = [UIColor greenColor];
    }else {
        
        //大连银行
        self.bigbankImageView.image = [UIImage imageNamed:@"bank_icon_dl"];
        self.bankView.backgroundColor = [UIColor redColor];
    }
    
    _banklabel.text = RmtModel.bankName;
    
    
    NSString * lastNumberStr = [NSString stringWithFormat:@"****    ****    ****     %@",RmtModel.lastNumber];
    _lastNumberLabel.text = lastNumberStr;
    
    
    _staylabel.text = [NSString stringWithFormat:@"还款日：%@",RmtModel.dueDate];
}
+(NSString *)ID{
    
    return @"cell";
}
@end
